package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.JobLicenceCreate;
import com.ruoyi.system.mapper.JobLicenceCreateMapper;
import com.ruoyi.system.service.JobLicenceCreateService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 作业许可证办理(JobLicenceCreate)表服务实现类
 *
 * @author makejava
 * @since 2022-11-23 09:20:09
 */
@Service("jobLicenceCreateService")
public class JobLicenceCreateServiceImpl implements JobLicenceCreateService {
    @Resource
    private JobLicenceCreateMapper jobLicenceCreateDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobLicenceCreate queryById(Integer id) {
        return this.jobLicenceCreateDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobLicenceCreate 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobLicenceCreate> queryByPage(JobLicenceCreate jobLicenceCreate, PageRequest pageRequest) {
        long total = this.jobLicenceCreateDao.count(jobLicenceCreate);
        return new PageImpl<>(this.jobLicenceCreateDao.queryAllByLimit(jobLicenceCreate, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobLicenceCreate> queryAll(JobLicenceCreate jobLicenceCreate) {
        return jobLicenceCreateDao.queryAll(jobLicenceCreate);
    }

    /**
     * 新增数据
     *
     * @param jobLicenceCreate 实例对象
     * @return 实例对象
     */
    @Override
    public JobLicenceCreate insert(JobLicenceCreate jobLicenceCreate) {
        this.jobLicenceCreateDao.insert(jobLicenceCreate);
        return jobLicenceCreate;
    }

    /**
     * 修改数据
     *
     * @param jobLicenceCreate 实例对象
     * @return 实例对象
     */
    @Override
    public JobLicenceCreate update(JobLicenceCreate jobLicenceCreate) {
        this.jobLicenceCreateDao.update(jobLicenceCreate);
        return this.queryById(jobLicenceCreate.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobLicenceCreateDao.deleteById(id) > 0;
    }
}
